package edu.towson.greenteam.command;

import edu.towson.greenteam.InformationAggregator;
import edu.towson.greenteam.Iterator;
import edu.towson.greenteam.menu.Menu;
import edu.towson.greenteam.menu.MenuItem;

public class CMDMenuByRating implements Command {
	
	InformationAggregator ia;
	int rating;
	
	public CMDMenuByRating(InformationAggregator ia, int rating) {
		this.ia = ia;
		this.rating = rating;
	}
	
	public Object execute() {
		Menu newMenuByRating = new Menu();
		Menu currentMenu = ia.getMenu();
		Iterator<MenuItem> i = currentMenu.getMenuRatingItr(rating);
		while (i.hasNext()) {
			newMenuByRating.add(i.next());
		}
		return newMenuByRating;
	}

}
